<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>login</title>
    <link href="../css/login.css" rel="stylesheet">
</head>

<body>
<div id="loginDiv" >

    <form action="${pageContext.request.contextPath}/login" method="post" id="form">
        <h1 id="loginMsg">登 录</h1>

        <div id="errorMsg">${login_msg} ${register_msg}</div>
        <%--<span id="pd"></span>--%>

        <p>用户名:<input id="username" name="username" value="${cookie.username.value}" type="text" onblur="pdusername()"></p>

        <p>密码:<input id="password" name="password" value="${cookie.password.value}" type="password" onblur="pdpassword()"></p>

        <p>记住密码:<input id="remember" name="remember" value="1" type="checkbox"></p>

        <div id="subDiv">
            <input type="submit" class="button" value="登录" id="btn">
            <input type="reset" class="button" value="重置">
            <a href="${pageContext.request.contextPath}/pages/register.jsp">没有账号？</a>
        </div>

    </form>

</div>


<%--
<script>

    function containSpace(example) {
        return example.includes(' ')
    }

    function checkLength(example) {
        if (example.length < 6) {
           return true;
        } else if (example.length > 12) {
           return true;
        } else return false;
    }


    function pdusername(){
       let username = document.getElementById("username").value;
       if (containSpace(username)){
           document.getElementById("pd").innerHTML="<br><font color='red'>账号中不能包含空格!</font>";
           document.getElementById("btn").disabled = false;
       }
        if (checkLength(username)){
            document.getElementById("pd").innerHTML="<br><font color='red'>账号长度应为6~12位!</font>";
            document.getElementById("btn").disabled = false;
        }

        if (containSpace(username)===false&&checkLength(username)===false){
            document.getElementById("pd").innerHTML="<br><font color='green'></font>";
        }

   }


   function pdpassword(){
       let password = document.getElementById("password").value;
       if (containSpace(password)){
           document.getElementById("pd").innerHTML="<br><font color='red'>密码中不能包含空格!</font>";
           document.getElementById("btn").disabled = false;
       }
       if (checkLength(password)){
           document.getElementById("pd").innerHTML="<br><font color='red'>密码长度应为6~12位!</font>";
           document.getElementById("btn").disabled = false;
       }

       if (containSpace(password)===false&&checkLength(password)===false){
           document.getElementById("pd").innerHTML="<br><font color='green'></font>";
       }
   }

</script>
--%>

</body>

</html>